package priv.tuyou.system.serviceImpl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import priv.tuyou.dao.IDao;
import priv.tuyou.exception.ServiceException;
import priv.tuyou.system.dao.IAdvertDao;
import priv.tuyou.system.po.Advert;
import priv.tuyou.system.service.IAdvertService;

@Service
public class AdvertServiceImpl implements IAdvertService{

	@Resource
	protected IDao dao;
	@Resource
	protected IAdvertDao advertDao;
	
	@Override
	public Advert add(String title, String outline, String cover, String content) throws ServiceException {
		
		Advert article = new Advert();
		article.setTitle(title);
		article.setOutline(outline);
		article.setCover(cover);
		article.setContent(content);
		dao.save(article);
		return article;
	}
	
	@Override
	public Advert update(long id, String title, String outline, String cover, String content) throws ServiceException {
		
		Advert article = dao.get(Advert.class, id);
		article.setTitle(title);
		article.setOutline(outline);
		article.setCover(cover);
		article.setContent(content);
		dao.update(article);
		return article;
	}
}
